<?php
/**
 * ProjectName: Grapes.
 * Created by LemonZ.
 * FileName: Balance.php
 * Date: 2019/2/14
 * Time: 16:01
 * Description:
 */

namespace app\admin\controller;


use app\common\controller\Admin;
use app\common\model\Balance as BalanceModel;
use app\common\model\UserTocash;
use think\facade\Request;

class Balance extends Admin
{
    /**
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function index()
    {
        $user_id = input('user_id','');
        if(Request::isAjax()){

            $data = input('param.');
            $balanceModel = new BalanceModel();
            return $balanceModel->tableData($data);
        }else{
            $this->assign('user_id',$user_id);
            return $this->fetch('index');
        }
    }

    /**
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function tocash()
    {
        if(Request::isAjax()){
            $data = input('param.');
            $tocashModel = new UserTocash();
            return $tocashModel->tableData($data);
        }else{
            return $this->fetch('tocash');
        }
    }

    /**
     * @return array|mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function tocashexamine(){
        if(!input('param.type')){
            return error_code(10001);
        }
        if(!input('param.id')){
            return error_code(10002);
        }
        $tocashModel = new UserTocash();
        return $tocashModel->examine(input('param.id'),input('param.type'));
    }
}